#!/bin/sh

CURDIR=${PWD}
SRCPACK=${CURDIR}/pack.src
SDKROOT=${CURDIR}/sdk

# cppunit
if [ ! -d ${CURDIR}/cppunit/cppunit-1.12.1 ]; then
        echo 'extracting cppunit...'
        tar zxf ${SRCPACK}/cppunit-1.12.1.tar.gz -C cppunit
fi
cd ${CURDIR}/cppunit/cppunit-1.12.1
./configure --prefix=${SDKROOT}
make install
cd ${CURDIR}

# icu
if [ ! -d ${CURDIR}/icu/icu ]; then
        echo 'extracting icu...'
        tar zxf ${SRCPACK}/icu4c-4_8_1-src.tgz -C icu
fi
cd ${CURDIR}/icu/icu/source
./configure --prefix=${SDKROOT}
make install
cd ${CURDIR}

# boost
if [ ! -d ${CURDIR}/boost/boost_1_47_0 ]; then
        echo 'extracting boost...'
        tar jxf ${SRCPACK}/boost_1_47_0.tar.bz2 -C boost
fi
cd ${CURDIR}/boost/boost_1_47_0
./bootstrap.sh --with-icu=${SDKROOT} --prefix=${SDKROOT}
./b2 install
cd ${CURDIR}

# ogre
if [ ! -d ${CURDIR}/ogre/ogre_src_v1-7-3 ]; then
	echo 'extracting ogre...'
	tar jxf ${SRCPACK}/ogre_src_v1-7-3.tar.bz2 -C ogre
fi
cd ${CURDIR}/ogre
BOOST_ROOT=${CURDIR}/sdk;export BOOST_ROOT
if [ -d build ] ; then
	rm -rf build
fi
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=${CURDIR}/sdk -G "Unix Makefiles" ../ogre_src_v1-7-3
cd ${CURDIR}



